<?php
class LandingController extends AppController {

    public $layout = 'main';

    function beforeFilter() {
        parent::beforeFilter();
        $this->set('nav','index');  
    }

    function form(){
    	$params = $this->request->data;
        $this->loadModel('UsersAppoint');  
    	if($this->request->is('post') && @$params['dosubmit']==1){ 
            if(empty($params['name'])){
                $this->ajaxReturn(4001, '请填写姓名!');  
            }
            if(empty($params['phone'])){
                $this->ajaxReturn(4001, '手机号不能为空!');  
            }
            if(!Ivf::isMobile($params['phone']))
                $this->ajaxReturn(4002, '请输入有效的11位手机号码!');  
            $db_data = array();
            $db_data['types'] =  0;
            $db_data['user_name'] =  $params['name'];
            $db_data['mobile'] =  $params['phone'];
            $db_data['description'] = $params['descrip'];
            $db_data['system'] = Ivf::getOSInfo(strtolower($_SERVER['HTTP_USER_AGENT']));
            $db_data['brand'] = Ivf::getOSBrand(strtolower($_SERVER['HTTP_USER_AGENT'])); 
            $db_data['source'] = "夜间挂号";
            $db_data['status'] = 0; 
            $db_data['ip'] = Ivf::getClientIp();; 
            $db_data['create_time'] = date("Y-m-d H:i:s",time()); 
            if(!$this->UsersAppoint->save($db_data)) 
                    $this->ajaxReturn(4005, '预约失败！'); 
              
            $this->ajaxReturn(200, '我们尽快与您取得联系!');    

        } 
    }

}